import numpy as np

arr = np.array([1, 2, 3, 4, 5])
x = arr.copy() #指向不同的位置
arr[0] = 42
print('After Copy & assign new value')
print(arr,arr.dtype,arr.ndim)
print(x,x.dtype,x.ndim)

arr = np.array([1, 2, 3, 4, 5])
x = arr.view() #指向相同的位置
arr[0] = 42
print('After View & assign new value')
print(arr,arr.dtype,arr.ndim)
print(x,x.dtype,x.ndim)

arr = np.array([1, 2, 3, 4, 5])
x = arr.view() #指向相同的位置
x[0] = 42 # 同样前面的操作。
print('After View & assign new value to view array')
print(arr,arr.dtype,arr.ndim)
print(x,x.dtype,x.ndim)

## Every NumPy array has the attribute base that returns None if the array owns the data.
## Otherwise, the base  attribute refers to the original object. base == None,
arr = np.array([1, 2, 3, 4, 5])
x = arr.copy()
y = arr.view()
print(x.base,arr.base, y.base )